import * as types from "./constants";
import { reqArtistList } from "@/api/artist";
import { message } from "antd";

const changeArtistListAction = artistList => ({
    type: types.CHANGE_ARTIST_LIST,
    artistList
});
export const changeCurrentTypeAction = currentType => ({
    type: types.CHANGE_CURRENT_TYPE,
    currentType
});
export const changeCurrentAreaAction = currentArea => ({
    type: types.CHANGE_CURRENT_AREA,
    currentArea
});

export const getArtistListAction = (area, type, alpha) => {
    return dispatch => {
        reqArtistList(area, type, alpha)
            .then(res => {
                if (res.code === 200) {
                    dispatch(changeArtistListAction(res.artists));
                }
            })
            .catch(() => {
                message.error("网络异常，请重试");
            });
    };
};